namespace TerritoryGame.Domain.ValueObjects;

public record Position(int X, int Y)
{
    public static Position Origin => new(0, 0);
    
    public double DistanceTo(Position other)
    {
        return Math.Sqrt(Math.Pow(X - other.X, 2) + Math.Pow(Y - other.Y, 2));
    }
    
    public bool IsWithinBounds(int maxWidth, int maxHeight)
    {
        return X >= 0 && X < maxWidth && Y >= 0 && Y < maxHeight;
    }
    
    public static Position operator +(Position a, Position b)
    {
        return new Position(a.X + b.X, a.Y + b.Y);
    }
    
    public static Position operator -(Position a, Position b)
    {
        return new Position(a.X - b.X, a.Y - b.Y);
    }
}
